package servlet.manage.introduct;

import dto.CompanyModelDto;
import dto.IntroDuctModelDto;
import net.sf.json.JSONArray;
import service.IIntroDuctService;
import service.impl.IntroDuctServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/IntroDuctAdd")
public class IntroDuctAddServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        req.setCharacterEncoding("UTF-8");//请求编码格式为utf-8
//        resp.setCharacterEncoding("UTF-8");//响应编码格式为utf-8
//        resp.setContentType("text/json;charset=utf-8");//解决传值乱码

        String content =req.getParameter("content");
        IntroDuctModelDto dto =new IntroDuctModelDto();
        dto.setContent(content);

        IIntroDuctService service =new IntroDuctServiceImpl();
        service.add(dto);

        JSONArray jsonArray=JSONArray.fromObject(service.add(dto));
        resp.getWriter().println(jsonArray);
    }
}
